package org.oy.sealogger.ui;

import java.awt.Image;
import java.awt.MediaTracker;
import java.awt.Toolkit;
import java.awt.image.ImageObserver;
import java.net.URL;

import javax.swing.JPanel;

import org.oy.sealogger.common.MessageQueue;

public class ImageLoader extends JPanel implements ImageObserver {
	
    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	

	public Image getImage(String name) {
        URL url = this.getClass().getResource(name);
        Image img = Toolkit.getDefaultToolkit().getImage(url);
        try {
            MediaTracker tracker = new MediaTracker(this);
            tracker.addImage(img, 0);
            tracker.waitForID(0);
        } catch (Exception e) {
        	MessageQueue.getInstance().warning("Open File", "Could not open the image: " + name);
        }
        return img;
    }
	

}
